package com.trgis.zhejiangimg;

import java.util.ArrayList;
import java.util.List;

/**
 * 2022/8/23
 *
 * @author fengyu
 */
public class WmtsTileMatrixSet {
    private String id;
    private List<TileLevelInfo> matrixSet = new ArrayList<>();
    private final List<Double> resolutions = new ArrayList<>();

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public List<TileLevelInfo> getMatrixSet() {
        return matrixSet;
    }

    public void setMatrixSet(List<TileLevelInfo> matrixSet) {
        this.matrixSet = matrixSet;
    }

    public void addResolution(double resolution) {
        this.resolutions.add(resolution);
    }

    public String getResolutions(){
        StringBuilder sb = new StringBuilder();
        resolutions.stream().sorted((d1, d2) -> d1 > d2 ? 0 : 1).forEach(d -> sb.append(d).append(", "));
        sb.deleteCharAt(sb.lastIndexOf(","));
        return sb.toString().trim();
    }

    public Double getFirstResolutions(){
        return resolutions.stream().max(Double::compareTo).get();
    }

    public long getTileCount() {
        return matrixSet.stream().mapToLong(TileLevelInfo::getCount).reduce(Long::sum).getAsLong();
    }
}
